//
//  OIPubListTableViewAdapter.m
//  EducationOID
//
//  Created by slz on 2017/5/25.
//  Copyright © 2017年 bnsr. All rights reserved.
//

#import "OIPubListTableViewAdapter.h"
#import "OIPubListModel.h"
#import "OIPubListTableViewCell.h"
#import "OIPublicDetailViewController.h"

@implementation OIPubListTableViewAdapter

- (TGMBaseModelActionData*)actionDataForRequestModelData:(MFWDataRequestType)type
{
    return [[OIPubListModel managedModelInstance] actionDataWithPub:_isPub];
}


- (CGFloat)model2UITableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

- (UITableViewCell *)model2UITableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    OIPubListItem * item = self.listData[indexPath.row];
    static NSString *bannerIdentifier = @"OIPubListTableViewCell";
    OIPubListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:bannerIdentifier];
    
    if(cell == nil)
    {
        cell = [[OIPubListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:bannerIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.nameLabel.text = item.name;
        cell.timeLabel.text = item.time;
    }

    return cell;
}

- (BOOL)model2UITableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    OIPubListItem * item = self.listData[indexPath.row];
    OIPublicDetailViewController * detailController = [[OIPublicDetailViewController alloc]init];
    detailController.itemId = item.itemId;
    [self.contextViewController.navigationController pushViewController:detailController animated:YES];
    return YES;
}

-(BOOL)supportPullRefreshHeader{
    return YES;
}


@end
